export default {
  init: function () {
    const ak = "b2BjBzadsBfEPAXxTG5h4scoeQyxDc21";
    const TMap_URL = `https://api.map.baidu.com/api?v=1.0&type=webgl&ak=${ak}&callback=onMapInitialize`;

    return new Promise((resolve, reject) => {
      // 地图异步加载回调处理
      window.onMapInitialize = function () {
        resolve(window.BMapGL);
      };

      // 插入script脚本
      const scriptNode = document.createElement("script");
      scriptNode.setAttribute("type", "text/javascript");
      scriptNode.setAttribute("src", TMap_URL);
      document.body.appendChild(scriptNode);
    });
  },
};
